<?php


namespace app\api\controller;

class Common extends ApiBase
{
	public function getCode()
	{
		return ShowCaptcha("api_" . $this->project["id"]);
	}
	public function fileUpdate()
	{
		$upload_config = json_decode($this->project["upload_config"], true);
		if (empty($upload_config["open"])) {
			$this->response(10039, "文件上传功能未开启");
		}
		if (!empty($upload_config["verify_graphic_code]"])) {
			if (empty($this->input["verify_code"])) {
				$this->response(10040, "需要传入图形验证码参数verify_code");
			} else {
				if (!CheckCaptcha($this->input["verify_code"], "apiCommon")) {
					$this->response(10041, "图形验证码不正确");
				}
			}
		}
		$ip = $this->client_ip;
		$result = \app\api\service\CommonService::fileUpdate($upload_config, $ip);
		if ($result["code"] == Code::success) {
			$this->response($result["code"], $result["msg"], $result["data"]);
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
}